package com.bw.flinkstreaming.source2.job1;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者QQ：43281991
 * 需求：collection当作数据源
 */
public class Job1FromCollection {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //数据源
        List<String> data = new ArrayList<String>();
        data.add("flink1");
        data.add("flink1");
        data.add("flink1");

        DataStreamSource<String> stringDataStreamSource = env.fromCollection(data);
        SingleOutputStreamOperator<String> result = stringDataStreamSource.map(new MapFunction<String, String>() {

            @Override
            public String map(String value) {
                return value + " map operator";
            }
        });

        result.print();
        env.execute("Job1FromCollection");
    }
}
